﻿using System;
using System.Collections.Generic;

namespace FlipRunner
{
    public static class ExtensionMethods
    {
        public static float NextFloat(this Random random)
        {
            return (float)random.NextDouble();
        }

        public static float NextFloat(this Random random, float min, float max)
        {
            float scale = random.NextFloat();
            return min + (max - min)*scale;
        }

        public static bool NextBool(this Random random)
        {
            return random.NextDouble() < 0.5;
        }

        public static int NextSign(this Random random)
        {
            return random.NextBool() ? 1 : -1;
        }

        public static T Last<T>(this IList<T> list)
        {
            return list[list.Count - 1];
        }
    }
}